package com.jyw.business.ast.domain.dto.web;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.jyw.business.ast.domain.AstConsumable;
import com.jyw.common.annotation.Excel;
import com.jyw.common.constant.Constants;
import com.jyw.common.utils.DateUtils;
import com.jyw.common.utils.SecurityUtils;
import com.jyw.common.utils.bean.BeanUtils;
import com.jyw.system.domain.vo.SimpleFileVo;
import com.jyw.system.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@ApiModel("耗材登记-请求实体")
public class AstConsumableSignDto {

    /** 名称 */
    @ApiModelProperty("名称")
    @NotEmpty(message = "不能为空")
    private String name;

    /** 规格型号 */
    @ApiModelProperty("规格型号")
    private String model;

    /** 供应商 */
    @ApiModelProperty("供应商")
    private Long supplierId;

    /** 分类(数据字典) */
    @ApiModelProperty("分类(数据字典)")
    private String type;

    /** 使用单位(数据字典) */
    @ApiModelProperty("使用单位(数据字典)")
    private String unit;

    /** 安全库存 */
    @ApiModelProperty("安全库存")
    private Integer safeReserve;

    /** 单价 */
    @ApiModelProperty("单价")
    private BigDecimal price;

    /** 备注 */
    @ApiModelProperty("备注")
    private String remark;

    /** 附件 */
    @ApiModelProperty("附件")
    private List<SimpleFileVo> enclosure;


    public AstConsumable buildAstConsumable(){
        AstConsumable consumable = new AstConsumable();
        BeanUtils.copyProperties(this,consumable);
        consumable.setRealReserve(0);
        consumable.setFrostReserve(0);
        consumable.setEnclosureId(FileUtils.fileToId(getEnclosure()));
        consumable.setRecordState(Constants.BOOL_TRUE);
        consumable.setCreateUser(SecurityUtils.getUserId());
        consumable.setCreateTime(DateUtils.getNowDate());
        return consumable;
    }
}
